class Computer:
    def __init__(self,brand,color,size):
        self.brand=brand
        self.color=color
        self.size=size
    def play_game(self):
        print("别打游戏了")
    def write_code(self):
        print("继续加油")
    def watch_video(self):
        print("仙剑奇侠传")
class Person:
    def __init__(self,name,age,dog):
        self.name=name
        self.age=age
        self.dog=dog
    def run_dog(self):
        print(f'{self.name}在遛小狗狗{self.dog}')
class Dog:
    def __init__(self,name,color,age):
        self.age = age
        self.name=name
        self.color=color
    def wangwang(self):
        print(f"{self.name}在汪汪叫")
#试一下方法
computer=Computer("华硕","black","1t")
computer.play_game()
xiaoma=Person("xiaoming",12,"大黄")
xiaoma.run_dog()
cat=Dog("大黄","white",2)
cat.wangwang()
class Student:
    def __init__(self,name,age,number):
        self.age = age
        self.name = name
        self.number = number

    def attend(self):
        print(f"{self.name} 到")

    def print_info(self):
        print(f"Name: {self.name}, Age: {self.age}, ID: {self.number}")
class Class:
    def __init__(self,name):
        self.student=["喻文波"]
        self.name=name
    def __add__(self, other):
        self.student.append(other)
    def __delete__(self, instance):
        self.student.remove(instance)
    def dianming(self):
        for student in self.student:
            student.attend()
    def calculate_average_age(self):
        if not self.student:
            return 0
        return sum(student.age for student in self.student) / len(self.student)
#再测试一下
xiaoma=Student("喻文波",12,22145)
xiaoma.attend()
xiaoma.print_info()
wuban=Class("5班")
wuban.__add__("喻文波")
wuban.dianming()
def input_age():
    while True:
        try:
            age = int(input("请输入您的年龄 (1-100): "))
            if 1 <= age <= 100:
                print(f"您输入的年龄是 {age}")
                break
            else:
                print("年龄应该在 1 到 100 之间，请再次尝试。")
        except ValueError:
            print("无效输入！请输入一个整数。")


